Output an XSD schema header that matches the GPX version we're writing.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 9 Feb 2005 16:33:13 +0000 (16:33 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 9 Feb 2005 16:33:13 +0000 (16:33 +0000)
(Yeah, this is a can of worms.)

gpsbabel/gpx.c

index c59db63db44fc5fc8bfcdf2359ab1ccd71dd31d6..2cd12d0d16e5d708a200c05b8b8700bdc11d5d33 100644 (file)
@@ -61,6 +61,7 @@ static route_head *rte_head;
 #define MYNAME "GPX"
 #define MY_CBUF 4096
 #define DEFAULT_XSI_SCHEMA_LOC "http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"
+#define DEFAULT_XSI_SCHEMA_LOC_FMT "\"http://www.topografix.com/GPX/%c/%c http://www.topografix.com/GPX/%c/%c/gpx.xsd\""
 
 /* 
  * Format used for floating point formats.  Put in one place to make it
@@ -1286,7 +1287,14 @@ gpx_write(void)
        fprintf(ofd, "creator=\"GPSBabel - http://www.gpsbabel.org\"\n");
        fprintf(ofd, "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
        fprintf(ofd, "xmlns=\"http://www.topografix.com/GPX/%c/%c\"\n", gpx_wversion[0], gpx_wversion[2]);
-       fprintf(ofd, "xsi:schemaLocation=\"%s\">\n", xsi_schema_loc ? xsi_schema_loc : DEFAULT_XSI_SCHEMA_LOC);
+       if (xsi_schema_loc) {
+               fprintf(ofd, "xsi:schemaLocation=\"%s\">\n", xsi_schema_loc);
+       } else {
+               fprintf(ofd,
+                       "xsi:schemaLocation=" DEFAULT_XSI_SCHEMA_LOC_FMT">\n",
+                       gpx_wversion[0], gpx_wversion[2],
+                       gpx_wversion[0], gpx_wversion[2]);
+       }
 
        if (gpx_wversion_num > 10) {    
                fprintf(ofd, "<metadata>\n");